package root.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import root.entity.vo.PageInfo;
import root.service.Lybservice;
import root.service.impl.Lybserviceimpl;

/**
 * Servlet implementation class Lybflushdata2
 */
@WebServlet("/Lybflushdata")
public class Lybflushdata2 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public Lybflushdata2() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String fenyepageindex = request.getParameter("fenyepageindex");
//		根据 留言标题， 内容， 对象， 等等信息 进行筛选，默认没有筛选条件
		String name = request.getParameter("name");
		String value = request.getParameter("value");
		String target = request.getParameter("target");
		String type = request.getParameter("type");
		int fenyeindex = 0;
		PageInfo page = new PageInfo();
		if(fenyepageindex==null||fenyepageindex.equals("")) {
			response.getWriter().write("error");
			return;
		}
		try {
			fenyeindex = Integer.valueOf(fenyepageindex);
			page.setFenyepageindex(fenyeindex);
		} catch (Exception e) {
			response.getWriter().write("error");
			return;
		}
		
		Lybservice service = new Lybserviceimpl();
		service.flushData(name,value,target,type,page);
		
		response.getWriter().write(JSON.toJSONString(page));
		
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
